package moving;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JComponent;
import javax.swing.Timer;

public class CircleComponent extends JComponent
{
   public CircleComponent()
   {
      sun = new Circle(10,10,100);
      listener = new TimerListener();
      t = new Timer(DELAY, listener);
      t.start();
   }
   
   public void paintComponent(Graphics g)
   {
      Graphics2D g2 = (Graphics2D) g;
      sun.draw(g2);
   }
   class TimerListener implements ActionListener
   {
      public void actionPerformed(ActionEvent e)
      {
         sun.move(10, 10);
         repaint();
         
      }
      
   }
   
   private Circle sun;
   private ActionListener listener;
   private Timer t;
   public static final int DELAY = 1000;
}
